package com.yao.shardingdemo.mapper;

import com.yao.shardingdemo.entity.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author Henry Yao
 */
@Mapper
@Component
public interface UserMapper {
    /**
     * 插入用户
     *
     * @param user 用户
     */
    @Insert("insert into t_user(uid,name,age) values(#{uid},#{name},#{age})")
    void insertUser(User user);

    /**
     * selectAllUser
     *
     * @return
     */
    @Select("select uid,name,age from t_user")
    @ResultType(User.class)
    List<User> selectAllUser();

    /**
     * selectUserById
     * @param uid
     * @return
     */
    @Select("select uid,name,age from t_user where uid = #{uid}")
    @ResultType(User.class)
    User selectUserById(int uid);
}
